<template>
	<view class="page">

		<u-search :showAction="true" v-model="svalue" actionText="搜索" placeholder="请输入客户" @search="search"
			@custom="search"></u-search>

		<view v-for="(item, index) in custList" :key="index">
			<u-cell icon="account-fill" :title="item.name">
				<u-tag v-if="item.area" slot="value" :text="item.area"></u-tag>
			</u-cell>
		</view>

		<u-empty mode="list" v-if="custList.length == 0"></u-empty>
	</view>
</template>

<script>
	import * as Config from '@/utils/config.js';
	export default {
		data() {
			return {
				svalue: '',
				custList: [],
				page: 1
			}
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			this.page++
			this.getList()
		},
		methods: {
			search(e) {
				this.page = 1
				this.getList()
			},

			getList() {
				uni.showLoading({
					title: '加载中'
				})
				uni.request({
					url: Config.baseUrl + '/api/app/custom.php?act=list',
					data: {
						name: this.svalue,
						page: this.page
					},
					success: (res) => {
						uni.hideLoading()
						this.custList = this.custList.concat(res.data.data)
					}
				});
			}

		},

	}
</script>

<style scoped lang="scss">
	.page {
		margin: 20rpx;

		.submit {
			margin-top: 80rpx;
			background: #1e4297;
			color: #fff;
		}
	}
</style>